package com.sky.wsp.guo.mi.utils;

import org.bouncycastle.util.encoders.Hex;

import java.io.UnsupportedEncodingException;

/**
 * @author wangshaopeng@talkweb.com.cn
 * @desccription 工具类：字节数组转16进制字符串
 * @date 2025/4/9
 */
public class HexUtil {
    public static String encode(byte data[]) {
        byte[] encodedData = Hex.encode(data);
        try {
            String encodeStr = new String(encodedData, "UTF-8");
            return encodeStr;
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
    }

    public static byte[] decode(String hexStr) {
        return Hex.decode(hexStr);
    }
}
